import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main2 {

    public static Queue<Integer> queue = new LinkedList<>(); //保存当前是多少楼层
    public static int A; //起始楼层
    public static int B; //最终楼层
    public static int n;
    public static boolean[] flag;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        flag = new boolean[n + 1];

        queue.offer(A);
        flag[A] = true;

        int count = bfs(arr);

        System.out.println(count);

        sc.close();
    }

    public static int bfs(int[] arr) {
        int count = 0;

        while (!queue.isEmpty()) {
            int size = queue.size();
            count++;
            while (size > 0) {
                size--;
                int num = queue.poll(); //当前楼层
                flag[num] = true;
                if (num == B) {
                    return count - 1;
                }
                int step = arr[num - 1];
                int x = num + step;
                int y = num - step;
                if (x == B || y == B) {
                    return count;
                }
                if (x > 0 && x <= n && !flag[x]) {
                    queue.offer(x);
                    flag[x] = true;
                }
                if (y > 0 && y <= n && !flag[y]) {
                    queue.offer(y);
                    flag[y] = true;
                }
            }
        }
        return -1;
    }
}
